package com.example.cola.common.dto;

import java.io.Serializable;

/**
 * 其他别名
 *
 * @author fenglin
 * @date 2022/8/14
 */
// +===========+===========+===============+
// | 分页响应前缀| 响应       | 统一返回（含有success字段）|
// +===========+===========+===============+
// | Paged     | Data      | CommonResult  |
// +-----------+-----------+---------------+
// | Paging    | ----------| ResultBase    |
// +-----------+-----------+---------------+
// | Pageable  | Response  | Result        |
// +-----------+-----------+---------------+
// | Page      | Resp      | ResultDTO     |
// +-----------+-----------+---------------+
// |           | 请求       | PageResult    |
// +-----------+-----------+---------------+
// |           | Request   |               |
// +-----------+-----------+---------------+
// |           | Query     |               |
// +-----------+-----------+---------------+
// |           | Param     |               |
// +-----------+-----------+---------------+
// |           |  Req      |               |
// +-----------+-----------+---------------+
// |           | 请求或响应  |               |
// +-----------+-----------+---------------+
// |           | DTO       |               |
// +-----------+-----------+---------------+
// |           | Info      |               |
// +-----------+-----------+---------------+
public class PagedData <T> implements Serializable {

	private static final long serialVersionUID = -3204431462841949993L;

	/**
	 * 结果实体
	 */
	private T data;
	/**
	 * 记录总数
	 */
	private Long totalCount = 0L;
	/**
	 * 当前页码
	 */
	private Integer currentPage;

	/**
	 * 分页大小
	 */
	private Integer pageSize;

	public static <T> PagedData<T> newData(T data) {
		PagedData<T> pagedData = new PagedData<>();
		pagedData.setData(data);
		return pagedData;
	}

	public PagedData<T> currentPage(Integer currentPage) {
		this.currentPage = currentPage;
		return this;
	}

	public PagedData<T> pageSize(Integer pageSize) {
		this.pageSize = pageSize;
		return this;
	}

	public PagedData<T> total(Long total) {
		this.totalCount = total;
		return this;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

	public Long getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(Long totalCount) {
		this.totalCount = totalCount;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public Integer getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(Integer currentPage) {
		this.currentPage = currentPage;
	}	
}
